package com.example.careycai.notepad;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
 * Created by carey.cai on 12/25/2015.
 */
public class MyDatabaseHelper extends SQLiteOpenHelper {
    public static final String CREATE_INFORMATION="create table information("
            +"id integer primary key autoincrement,"
            +"title text,"
            +"place text,"
            +"content text,"
            +"time text)";

    public static final String CREATE_REGISTER="create table register("
            +"id integer primary key autoincrement,"
            +"name text,"
            +"password text)";
    private  Context mContext;

    public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
         super(context, name, factory, version);
         mContext=context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
         db.execSQL(CREATE_INFORMATION);
         db.execSQL(CREATE_REGISTER);
        Toast.makeText(mContext,"初始化成功",Toast.LENGTH_LONG).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
